<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Good extends Model
{
    //
    protected $table = 'goods';



    public function setImgAttribute($img)
    {
        if (is_array($img)) {
            $this->attributes['img'] = implode(',',array_filter($img));
        }
    }

    public function getImgAttribute($img)
    {
        return explode(',',$img);
    }



    public function color(){

        return $this->hasOne(Color::class,'id','color_id');
    }


    public function material(){

        return $this->hasOne(Material::class,'id','material_id');
    }

}
